<?php
/*
 * Created on 2012-8-22
 * Creater :cnluckylee
 * Creater mail:cnlucklee@gmail.com
 */
class cronController extends Controller {

        public function __construct() {
                parent::__construct();
        }
//获取类型名称和url地址
        public function catch_ClassName() {
        		$data = array();//最终数据
        		$url_arr = array();//url地址数组
                $curl_muilt = $this->load('curl_muilt',FALSE);
				$main_url = "http://www.myexception.cn/";
				$url_arr[] = $main_url;
				$page = $curl_muilt->remote($url_arr);
				$pattern = '/<ul class="b_c_u">(.*)<div class="b">/isU';
				preg_match_all($pattern,$page[0],$out);
				//过滤后的数据
				$data_class = $out[1][0];
				$pattern = '/href="(.*)">(.*)<\/a>/isU';
				preg_match_all($pattern,$data_class,$out2);

				foreach($out2[1] as $k=>$v)
				{
					$url_arr = array();
					$url_arr[] = $v;
					$page = $curl_muilt->remote($url_arr);
					$pattern = '/<a>共&nbsp;(.*)&nbsp;页: <\/a>/isU';
					preg_match_all($pattern,$page[0],$out3);
					$pageNum = $out3[1][0];				
					$data[] = array('classHref'=>htmlspecialchars($v),'className'=>htmlspecialchars($out2[2][$k]),'pageNum'=>intval($pageNum));			
				}
				$model = $this->model('corn');
				$model->saveClassName($data);
        }
//获取详细资料
		public function catch_page()
		{
			$model = $this->model('corn');
			$id = intval(isset($_GET['classid'])?$_GET['classid']:'');
			$urls = $model->showUrl($id);
			
		}
}
?>
